<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Created by PhpStorm.
 * User: gavin
 * Date: 15-3-25
 * Time: 下午6:12
 */
class Ghc_sort_model extends CI_Model
{

    public function __construct()
    {
        parent::__construct();
        //装载database
        $this->load->database();
    }

    /**
     * @param $sortname
     * @param null $alias
     * @param null $taxis
     * @param null $desciption
     * 默认插入
     */
    public function insert($sortname,$alias=null,$taxis=null,$description=null)
    {
        $value['sortname'] = $sortname;
        $value['alias'] = $alias;
        $value['taxis'] = $taxis;
        $value['description'] = $description;
        $this->db->insert('ghc_sort',$value);
    }

    /**
     * @return mixed
     * 获取分类信息
     */
    public function getSorts()
    {
        $sql = sprintf("select * from ghc_sort");
        $query = $this->db->query($sql);
        return $query->result();
    }

    public function getSortNameBySid($sid)
    {
        $sql = sprintf("select * from ghc_sort where sid=%s",$sid);
        $query = $this->db->query($sql);
        return $query->first_row()->sortname;
    }
}
